/** BEGIN SET THIS SETTING FOR DEV/PRODUCTION **/

var this_server = 'ads.shoppingads.com';

/** END SET THIS SETTING FOR DEV/PRODUCTION **/

function scrubSXX(str)
{
    str = str.replace(/eval\(/g, "");
    str = str.replace(/javascript:/g, "");
    str = str.replace(/[^A-Za-z0-9# \-;\,_]/g, "");
	return str;
}

var keywords = "";

var ad_format =  shoppingads_ad_width+'x'+shoppingads_ad_height;
var newcode;
var shoppingads_ad_kw;

if(shoppingads_ad_kw) {
	shoppingads_ad_kw = shoppingads_ad_kw.replace(new RegExp("\\s+", "g"),"_");
}

var shoppingads_options;
if(!shoppingads_options) { shoppingads_options = ""; }

var shoppingads_color_border;
if(!shoppingads_color_border) { shoppingads_color_border = ""; }

var shoppingads_color_bg;
if(!shoppingads_color_bg) { shoppingads_color_bg = ""; }

var shoppingads_color_heading;
if(!shoppingads_color_heading) { shoppingads_color_heading = ""; }

var shoppingads_color_text;
if(!shoppingads_color_text) { shoppingads_color_text = ""; }

var shoppingads_color_link;
if(!shoppingads_color_link) { shoppingads_color_link = ""; }

var shoppingads_new_ad;
if(!shoppingads_new_ad) { shoppingads_new_ad = ""; }

var shoppingads_new_ad_color;
if(!shoppingads_new_ad_color) { shoppingads_new_ad_color = ""; }

/* Set ad to Shopping Ad Type */
var shoppingads_type;
if(!shoppingads_type) { shoppingads_type = "SA"; }

var shoppingads_type;
if(!shoppingads_type) { shoppingads_type = "SA"; }

var shoppingads_attitude;
if(!shoppingads_attitude) { shoppingads_attitude = ""; }


if(
/* classic and redesigned */
(ad_format == "160x600") ||
(ad_format == "120x600") || 
(ad_format == "300x250") || 
(ad_format == "336x280") || 
(ad_format == "125x125") || 
(ad_format == "180x150") || 
(ad_format == "120x240") || 
(ad_format == "250x250") || 
(ad_format == "468x60") || 
(ad_format == "234x60") || 
(ad_format == "728x90") ||
/* Promo ads */
(ad_format == "180x200") ||
(ad_format == "180x353") ||
(ad_format == "180x506") ||
(ad_format == "227x159") ||
(ad_format == "401x159") ||
(ad_format == "575x159")
){
	newcode = "<iframe name='shoppingads_ad_frame' height='" + scrubSXX(shoppingads_ad_height) + "' width='"+scrubSXX(shoppingads_ad_width)+"' frameborder='0' marginwidth='0' marginheight='0' vspace='0' hspace='0' allowtransparency='true' scrolling='no' src=\"http://"+this_server+"/pagead/ads?ad_client="+scrubSXX(shoppingads_ad_client)+"&campaign="+scrubSXX(shoppingads_ad_campaign)+"&format="+ad_format+"&b="+scrubSXX(shoppingads_color_border)+"&bg="+scrubSXX(shoppingads_color_bg)+"&h="+scrubSXX(shoppingads_color_heading)+"&d="+scrubSXX(shoppingads_color_text)+"&l="+scrubSXX(shoppingads_color_link)+"&ad_kw="+scrubSXX(shoppingads_ad_kw)+"&kw="+scrubSXX(keywords)+"&opt="+scrubSXX(shoppingads_options)+"&new_ad="+scrubSXX(shoppingads_new_ad)+"&new_ad_color="+scrubSXX(shoppingads_new_ad_color)+"&ads_type="+scrubSXX(shoppingads_type)+"&attitude="+scrubSXX(shoppingads_attitude)+"\"></iframe>";
} else {
	newcode = "<span style=\"font-family:Arial; font-weight:bold; color:#ff0000;\">Warning: There was an error displaying your ShoppingAds advertisement.<br/> Please re-configure your ad code at: Shoppingads.com</span>";
}
document.write(newcode);
